﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.Util;
using DotNet.Common.NHibernateUtil;
using NHibernate;
using ZLCMS.Data.Model;
using ZLCMS.Business.DwzFrame;

namespace ZLCMS.Web.SystemManage.Template.Web
{
    public partial class ParamConfig : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CmsUserTemplateInfo usrTemp = null;
            int utid = TemplateUtil.GetUserTemplateId(UserKit.GetUserAccountWithoutException());
            using (ISession session = SessionFactoryHelper.CreateSession())
            {
                usrTemp = session.Get<CmsUserTemplateInfo>(utid);

                if (!IsPostBack)
                {

                    paramGrid.Columns.Add(new ListItem() { Text = "参数代码", Value = "ParamCode" });
                    paramGrid.Columns.Add(new ListItem() { Text = "参数名", Value = "ParamName" });
                    paramGrid.Columns.Add(new ListItem() { Text = "参数值", Value = "ParamValue" });

                    paramGrid.Value = usrTemp.Params;
                }
                else
                {
                    usrTemp.Params = paramGrid.Value;
                    session.SaveOrUpdate(usrTemp);
                    session.Flush();
                    new FrameHelper(this).Alert(new ReturnCode() { statusCode = 200, message = "操作成功" });
                }
            }

        }
    }
}